import { defineAsyncComponent, type App, type Component } from 'vue'
import '@/components/SvgIcon/symbol'

const components: Record<string, Component> = {
  MonacoEditor: defineAsyncComponent(() => import('@/components/MonacoEditor/index.vue')),
  Loading: defineAsyncComponent(() => import('@/components/Loading/index.vue')),
  SvgIcon: defineAsyncComponent(() => import('@/components/SvgIcon/index.vue')),
  PageMaking: defineAsyncComponent(() => import('@/components/PageMaking/PageMaking.vue')),
  PageMakingItem: defineAsyncComponent(() => import('@/components/PageMaking/PageMakingItem.vue')),
  CodeEditor: defineAsyncComponent(() => import('@/components/viewEditor/CodeEditor.vue')),
  DataSource: defineAsyncComponent(() => import('@/components/viewEditor/DataSource.vue')),
  ColumnSetting: defineAsyncComponent(() => import('@/components/viewEditor/ColumnSetting.vue')),
  CustomComponent: defineAsyncComponent(() => import('@/components/viewEditor/CustomComponent.vue')),
  DataWatcher: defineAsyncComponent(() => import('@/components/viewEditor/DataWatcher.vue')),
  DataRule: defineAsyncComponent(() => import('@/components/viewEditor/DataRule.vue')),
  TabpaneSetting: defineAsyncComponent(() => import('@/components/viewEditor/TabpaneSetting.vue')),
  TableColumnSetting: defineAsyncComponent(() => import('@/components/viewEditor/TableColumnSetting.vue'))
}

export default function setupGlobalComponent(app: App) {
  Object.keys(components).forEach(key => {
    app.component(key, components[key])
  })
} 